<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class checkRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [ 

            'nickname' => 'sometimes|required|regex:/^\w{6,16}$/|unique:tests,nickname',
            'phone' => 'required|regex:/^1[345789]\d{9}$/',
            'password' => 'required|regex:/^\w{6,20}$/',
            'Captcha' => 'sometimes|required'
            ];

    }

    public function messages()
    {

        return [

            'nickname.required' => '用户名不能为空',
            'nickname.regex' => '用户名格式不对',
            'nickname.unique' => '用户名已经存在',
            'phone.required' => '手机号必须填',
            'phone.regex' => '手机号格式不对',
            'password.required' => '密码必须填',
            'password.regex' => '密码格式不对',
            'Captcha.required' => '验证码必须填'
        ];
    }
}
